var app=getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    logo:"/image/logo.png",
    pre_url: '/pages/index/index',
    userInfo: {},
    canIUse: wx.canIUse('button.open-type.getUserInfo')
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var pre_url = ''
    if (options != undefined && options.url != undefined) {
      pre_url = options.url;
    } else if(options != undefined && options.is_storage_url != undefined)  {
      pre_url = wx.getStorageSync('auth_url');
    }else{
      pre_url = '/pages/index/index';
    }
    this.setData({
      pre_url: pre_url
    })
  },

  frmClick(e) {
    app.saveFormId(e.detail.formId);
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    
  },
  quickLogin: function () {
    app._login();
  },
  bindGetUserInfo: function (e) {

    wx.setStorageSync("access_info", e);
    var that = this;

    var userInfo = e.detail.userInfo;
    
    if (userInfo == undefined || userInfo == '') {
      return;
    }

    this.setData({
      userInfo: userInfo
    });

    wx.setStorage({
      key: "userInfo",
      data: userInfo
    });

    app._login(that.data.pre_url);
  },
  cancelLogin () {
    let page = this;
    app.forwardPage(page.data.pre_url)
  }
})